﻿<UserControl x:Class="Schedulr.Plugins.MonitorFolders.MonitorFoldersPluginSettingsControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:w="http://schemas.jelle.druyts.net/2010/xaml/presentation"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <UserControl.Resources>
        <w:EnumToBooleanConverter x:Key="enumConverter" />
    </UserControl.Resources>
    <Grid>
        <StackPanel Orientation="Vertical">
            <TextBlock Foreground="{DynamicResource UserMessageFontBrush}" Margin="0,0,0,5" TextWrapping="Wrap">
                When the account is activated, it will look for new files in the specified folders and add them to the queue (in the order they were added to the folder).<LineBreak />
                You can also start the discovery manually if new files were added since you launched the application.
            </TextBlock>
            <GroupBox Header="Folders">
                <StackPanel Orientation="Vertical">
                    <WrapPanel Margin="0,0,0,5">
                        <Button Content="Add Folder..." x:Name="addFolderButton" Command="{Binding Path=AddFolderToMonitorCommand}" ToolTip="{Binding Path=AddFolderToMonitorCommand.Description}" />
                        <Button Content="Discover Now" x:Name="discoverNowButton" Command="{Binding Path=DiscoverMonitoredFoldersCommand}" ToolTip="{Binding Path=DiscoverMonitoredFoldersCommand.Description}" Margin="5,0,0,0" />
                    </WrapPanel>
                    <ScrollViewer MaxHeight="100" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto">
                        <ItemsControl x:Name="foldersToMonitorItemsControl" ItemsSource="{Binding Path=Settings.FoldersToMonitor}">
                            <ItemsControl.ItemTemplate>
                                <DataTemplate>
                                    <StackPanel Orientation="Horizontal" Margin="0,0,0,5">
                                        <Button Content="Remove" Command="{Binding Path=DataContext.RemoveFolderToMonitorCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ItemsControl}}" ToolTip="{Binding Path=DataContext.RemoveFolderToMonitorCommand.Description, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ItemsControl}}" CommandParameter="{Binding}" Margin="0,0,5,0" />
                                        <TextBlock Text="{Binding}" VerticalAlignment="Center" />
                                    </StackPanel>
                                </DataTemplate>
                            </ItemsControl.ItemTemplate>
                        </ItemsControl>
                    </ScrollViewer>
                </StackPanel>
            </GroupBox>
            <GroupBox Header="Settings">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="*" />
                    </Grid.ColumnDefinitions>
                    <StackPanel Grid.Row="0" Grid.Column="0" Orientation="Horizontal">
                        <ComboBox Margin="0,0,5,0">
                            <ComboBoxItem Content="Include" IsSelected="{Binding Path=Settings.SearchMode, Mode=TwoWay, Converter={StaticResource enumConverter}, ConverterParameter=Include}" />
                            <ComboBoxItem Content="Exclude" IsSelected="{Binding Path=Settings.SearchMode, Mode=TwoWay, Converter={StaticResource enumConverter}, ConverterParameter=Exclude}" />
                        </ComboBox>
                        <Label Content="files (separate multiple entries with &quot;;&quot;)" VerticalAlignment="Center" Margin="0,0,5,0" />
                    </StackPanel>
                    <TextBox Grid.Row="0" Grid.Column="1" Text="{Binding Path=Settings.SearchPattern, Mode=TwoWay}" VerticalAlignment="Center">
                        <TextBox.Style>
                            <Style TargetType="TextBox">
                                <Setter Property="Visibility" Value="Hidden" />
                                <Style.Triggers>
                                    <DataTrigger Binding="{Binding Path=Settings.SearchMode}" Value="Include">
                                        <Setter Property="Visibility" Value="Visible" />
                                    </DataTrigger>
                                </Style.Triggers>
                            </Style>
                        </TextBox.Style>
                    </TextBox>
                    <TextBox Grid.Row="0" Grid.Column="1" Text="{Binding Path=Settings.ExcludePattern, Mode=TwoWay}" VerticalAlignment="Center">
                        <TextBox.Style>
                            <Style TargetType="TextBox">
                                <Setter Property="Visibility" Value="Hidden" />
                                <Style.Triggers>
                                    <DataTrigger Binding="{Binding Path=Settings.SearchMode}" Value="Exclude">
                                        <Setter Property="Visibility" Value="Visible" />
                                    </DataTrigger>
                                </Style.Triggers>
                            </Style>
                        </TextBox.Style>
                    </TextBox>
                    <CheckBox Grid.Row="1" Grid.ColumnSpan="2" IsChecked="{Binding Path=Settings.SearchRecursive}" Margin="0,5,0,0"><Label Content="Search all subfolders as well" /></CheckBox>
                    <Label Grid.Row="2" Grid.Column="0" Content="Batch handling" VerticalAlignment="Center" Margin="0,5,5,0" />
                    <ComboBox Grid.Row="2" Grid.Column="1">
                        <ComboBoxItem Content="Create a batch per discovered picture or video" IsSelected="{Binding Path=Settings.BatchMode, Mode=TwoWay, Converter={StaticResource enumConverter}, ConverterParameter=BatchPerFile}" />
                        <ComboBoxItem Content="Create a batch per folder in which pictures or videos were discovered" IsSelected="{Binding Path=Settings.BatchMode, Mode=TwoWay, Converter={StaticResource enumConverter}, ConverterParameter=BatchPerFolder}" />
                        <ComboBoxItem Content="Create a single batch for all new pictures and videos" IsSelected="{Binding Path=Settings.BatchMode, Mode=TwoWay, Converter={StaticResource enumConverter}, ConverterParameter=SingleBatch}" />
                    </ComboBox>
                </Grid>
            </GroupBox>
        </StackPanel>
    </Grid>
</UserControl>